package com.example.mapstruct_demo.service.mapper;

import com.example.mapstruct_demo.pojo.dto.UserDto;
import com.example.mapstruct_demo.pojo.entity.User;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @author 77229
 */
@Mapper
public interface UserMapper {
    UserMapper INSTANCE = Mappers.getMapper(UserMapper.class);

    @Mapping(source = "id", target = "userId")
    @Mapping(source = "username", target = "name")
    @Mapping(source = "tags", target = "tagList")
    User dto2do(UserDto userDto);

    @Mapping(target = "id", source = "userId")
    @Mapping(target = "username", source = "name")
    @Mapping(target = "tags", source = "tagList")
    UserDto do2dto(User user);
}
